(function ($) {
	AjaxSolr.ContextMenuWidget = AjaxSolr.AbstractWidget.extend({
		menuStyle: {
			width: '150px'
		},
		itemStyle: {
			'font-size': '0.7em'
		},

		itemHoverStyle: {
		},
		menu: {
			"interactions":{
				"label":"Get Interactions",
				"action":function(t){
					var protein= t.id.substr(5);
					var result = Manager.widgets["currentsearch"].requestInteractionsByProtein(protein);
				}
			},
			"hide":{
				"label":"Hide",
				"action":function(t){
					var protein= t.id.substr(5);
					var rule= {location:"Current Graphic",action:{name:"Hide",type:"single"},target:"Proteins",condition:"accession number",parameters:["equals",protein]};
					Manager.widgets["ruler"].ruler.addActiveRule(rule);
				}
			},
			"label":{
				"label":"Show/Hide Label",
				"action":function(t){
					Manager.widgets["graph"].graph.swapShowLegend("#"+t.id+" .legend");
				}
			},
			"lock":{
				"label":"Release",
				"action":function(t){
					var protein= t.id.substr(5);
					Manager.widgets["graph"].graph.swapFixed(protein);
				}
			},
			"highlight":{
				"label":"Highlight",
				"action":function(t){
					var protein= t.id.substr(5);
					var rule= {location:"Current Graphic",action:{name:"Highlight",type:"single"},target:"Proteins",condition:"accession number",parameters:["equals",protein]};
					Manager.widgets["ruler"].ruler.addActiveRule(rule);
				}
			},
			"highlight_p":{
				"label":"Highlight Interactors",
				"action":function(t){
					var protein= t.id.substr(5);
					var rule= {location:"Current Graphic",action:{name:"Highlight",type:"single"},target:"Proteins",condition:"interactions with",parameters:[protein]};
					Manager.widgets["ruler"].ruler.addActiveRule(rule);
				}
			},
			"highlight_i":{
				"label":"Highlight Interactions",
				"action":function(t){
					var protein= t.id.substr(5);
					var rule= {location:"Current Graphic",action:{name:"Highlight",type:"single"},target:"Interactions",condition:"protein",parameters:[protein]};
					Manager.widgets["ruler"].ruler.addActiveRule(rule);
				}
			}

		},
		bindings: null,
		init: function(){
			var self=this;
			self.bindings={};
			var html = '<div  class="contextMenu" id="myMenu1"><ul>';
			for (var key in self.menu){
				html +=	'<li id="'+key+'">'+self.menu[key].label+'</li>';
				self.bindings[key] = self.menu[key].action;
			}
			html +=	'</ul></div>';
			$("body").append(html);
		}		
	});
})(jQuery);